package MR;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class Map extends Mapper<LongWritable, Text, LongWritable, IntWritable> {
    private LongWritable word = new LongWritable();
    private IntWritable one = new IntWritable(1);

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        // 获取⼀⾏
        String word = value.toString();
        //因为一行只有一个单词，这里就不用切割，遍历了
        this.word.set(Integer.parseInt(word));
        //输出
        context.write(this.word, one);
    }
}